Repository navigation
feat(context): add wait_for_new_page, a block for pages and deprecate windows - #711
Merged
Merged
Conversation
wait_for_new_page runs a block and returns the page it opens, in a tab or a window, with opener: only the pages opened by that page. The context matches the opener id of each new page target against the waiting calls, so neither pages nor targets need to know each other.
windows only listed the pages another page opened and was used to pick the one just opened by its position. wait_for_new_page returns that page directly, so windows warns now and goes away in 0.22. Target#window? goes with it, it called a page with an opener a window, opener_id says the same.
route
force-pushed
the
feat/page-popups
branch
from
November 20, 2026 16:51
4a1f87e to
a92bfc9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
context.wait_for_new_page { ... }runs the block and returns the page it opens, in a tab or a window, e.g. throughwindow.openor a link withtarget="_blank". It returnsnilif no page opens in time,wait_for_new_page!raisesFerrum::TimeoutErrorinstead.opener:limits it to the pages opened by one page,timeout:bounds the block and the new page together.browser.wait_for_new_pageis the default context's.pagesof a context and of the browser takes a block that selects targets, sopages(&:opener_id)returns the pages opened by another page.context.windows(andbrowser.windows) andtarget.window?are deprecated and will be removed in 0.22.Why
windowslisted only the pages another page had opened and was used aswindows(:last)to pick the one just opened by its position in a list. It also called those pages "windows", whilewindow_id,window_boundsand:window_sizeare about the OS window.wait_for_new_pagereturns the opened page directly: the call is registered before the block runs and the context matches the opener id of each new page target against it, so a page that opens before the block returns is not missed. Pages and targets still only know ids.The block of
pagesfilters targets before connecting to them, so the pages it leaves out are not attached to.Notes
rel="noopener"is covered, Chrome reports the opener of its target.